package com.lanou3g.code0426;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/26;
 * Otherwise, I don't know who created it either
 */

public class Test03 {
    public static void main(String[] args) {
        String sql = "SELECT count(*) FROM stu WHERE sname = 'aaa' OR 1 = 1";
        Statement statement = JDBCUtil.getStatement();

        // 代理模式
        try {
            ResultSet resultSet = statement.executeQuery(sql);
            resultSet.next();
            System.out.println(resultSet.getInt(1));
            statement.execute("drop TABLE teacher");
//            if (rows > 0){
//                System.out.println("成功");
//            }else {
//                System.out.println("失败");
//            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        JDBCUtil.closeResource(statement);// 关闭资源


        JDBCUtil.closeConn();//放在 Main方法的最后一行
        // 整个项目 写这一遍 就可以了,别写太多,千万别写太多
    }
}
